/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
class Solution {
    private int k;
    private int res = 0;
    public int kthLargest(TreeNode root, int k) {
        this.k = k;
        recur(root);
        return res;
    }
    private void recur(TreeNode root){
        if(root == null){
            return;
        }
        recur(root.right);
        if(this.k == 0){
            return;
        }
        if(--this.k == 0){
            res = root.val;
            return;
        }
        recur(root.left);
    }
}